﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Test1
{
    /*    1、假设要完成一个学校的校园管理信息系统，在员工管理系统中有不同的人员信息，包括学生信息、教师信息等。

    为学生信息、教师信息创建两个类，并在两个类中分别定义属性和方法，在学生类中定义编号（Id）、姓名（Name）、
    性别（Sex）、身份证号（Cardid）、联系方式（Tel）、专业（Major）、年级（Grade）7 个属性，
    并定义一个方法在控制台输出这些属性的值。

    用同样的方法创建教师信息类（Teacher），属性包括编号（Id）、姓名（Name）,性别 （Sex）、身份证号（Cardid）、
    联系方式（Tel）、职称（Title）、工资号（Wageno），并将上 述属性输岀到控制台。

    将 Student 类和 Teacher 类中共有的 属性抽取出来定义为一个类Person，并让Student和Teacher继承Person
    每个类都要有一个输出属性的方法。
    每个类都要有初始化数据的有参构造方法。*/


    class Program1
    {
        static void Main(string[] args)
        {
            Person student1 = new Student(1, "nicola", '男', "ads646", 64616161616, "数学", 3);
            Person teacher1 = new Teacher(1, "acheles", '女', "641654ads", 4984646, "语文老师", "123");

            student1.SayHello();
            teacher1.SayHello();
        }

        class Person
        {
            private int _id;
            private string _name;
            private char _sex;
            private string _cardid;
            private long _tel;

            public int Id { get => _id; set => _id = value; }
            public string Name { get => _name; set => _name = value; }
            public char Sex { get => _sex; set => _sex = value; }
            public string Cardid { get => _cardid; set => _cardid = value; }
            public long Tel { get => _tel; set => _tel = value; }

            protected Person(int id, string name, char sex, string cardid, long tel)
            {
                Id = id;
                Name = name;
                Sex = sex;
                Cardid = cardid;
                Tel = tel;
            }
            public Person()
            {

            }

            public virtual void SayHello()
            {
                Console.WriteLine($"my id is {this.Id},my name is {this.Name}," +
                    $"my sex is {this.Sex},my cardid is {this.Cardid},my tel is {this.Tel}");
            }
        }

        class Student : Person
        {
            public Student()
            {

            }
            public Student(int id, string name, char sex, string cardid, long tel, string major, int grade)
                : base(id, name, sex, cardid, tel)
            {
                this.Major = major;
                this.Grade = grade;
            }

            public string Major { get; set; }
            public int Grade { get; set; }


            public override void SayHello()
            {
                Console.Write("i am a student ");
                base.SayHello();
                Console.WriteLine($"my major is {this.Major},my grade is {this.Grade}");
            }
        }

        class Teacher : Person
        {
            public Teacher(int id, string name, char sex, string cardid, long tel, string title, string wageno)
                : base(id, name, sex, cardid, tel)
            {
                this.Title = title;
                this.Wageno = wageno;
            }

            public string Title { get; set; }
            public string Wageno { get; set; }

            public Teacher()
            {

            }
            public override void SayHello()
            {
                Console.Write("i am a teacher ");
                base.SayHello();
                Console.WriteLine($"my title is {this.Title},my wageno is {this.Wageno}");
            }

        }
    }
}
